package com.feeyo.groundservice.base_util

import com.blankj.utilcode.util.GsonUtils
import com.google.gson.JsonObject
import java.lang.reflect.Type
import java.util.ArrayList

/**
 *作者：70893 on 2025-09-17
 *描述：GsonUtils扩展类
 */


/**
 * model => json string
 * **/
fun Any.toJson(): String {
    return GsonUtils.toJson(this)
}

/**
 * 格式化json string => model
 * **/
fun <T> String.fromJson(cls: Class<T>): T {
    return GsonUtils.fromJson(this, cls)
}

/**
 * 格式化json string => model
 * **/
fun <T> String.fromJson(cls: Type): T {
    return GsonUtils.fromJson(this, cls)
}


/**
 * 格式化json string => List
 * eg:fromListJson(object : TypeToken<List<RecorderBO>>() {}.type)
 * **/
fun <T> String.fromListJson(type: Type): ArrayList<T> {
    return GsonUtils.fromJson(this, type)
}